﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSSystem.BLL;

namespace WebUI.Controls
{
    public partial class TransferViewerCtrl : BaseEditControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblCompany.Text = Branches.CurrentBranch.s_Name;
                lblAddress.Text = Branches.CurrentBranch.s_Address;
                lblABN.Text = Branches.CurrentBranch.s_ABN;
                lblFax.Text = Branches.CurrentBranch.s_Fax;
                lblPhone.Text = Branches.CurrentBranch.s_Phone;
                //litFooter.Text = SysVars.InvoiceFooter;
                
            }
        }

        protected void btnLoad_OnClick(object sender, EventArgs e)
        {
            if (hidID.Value != "")
                LoadTransferByID(int.Parse(hidID.Value));
        }

        public void LoadTransferByID(int transID)
        {
            View_Transfers tf = View_Transfers.GetByID(transID);
            if (tf.RowCount <= 0)
                return;

            lblCustomer.Text = tf.s_ToName;
            lblCustomerAddress.Text = tf.s_ToAddress;
            lblCustomerFax.Text = tf.s_ToFax;
            lblCustomerPhone.Text = tf.s_ToPhone;
            lblDate.Text = tf.TransferedDate.AddHours(SystemVariables.SysVars.TimeZone).ToString(SystemVariables.SysVars.DateFormat);
            transferDetails.TransferDetails = View_TransferDetails.LoadByTransferID(transID);
            transferDetails.Refresh();
            lblSalePerson.Text = tf.s_FullName;
            litNote.Text = "<b>Note:</b>&nbsp;" + tf.s_Description;
            divInvoiceNo.InnerHtml = Utilities.GenerateBarCode(tf.s_TransferNO);
            lblInvoiceNo.Text = tf.s_TransferNO;
        }

    }
}